package com.yf.cl.initializaton;

/*
 若该类具有父类，JVM会保证子类的clinit()执行前，父类的clinit已经执行完毕
 */
public class ClinitExtendsTest {
    static class Ancestor {
        public static int A = 1;

        static {
            A = 2;
        }
    }

    static class Descendant extends Ancestor {
        public static int B = A; //若父类clinit方法执行完成，此时A=2,B=2
    }

    public static void main(String[] args) {
        System.out.println(Descendant.B); // 2
    }

}
